//
//  HistorySearchVC.m
//  LLSearchViewController
//
//  Created by 李龙 on 2017/8/22.
//  Copyright © 2017年 李龙. All rights reserved.
//

#import "HistorySearchVC.h"
#import "HistorySearchHistroyViewP.h"
#import "LLSearchVCConst.h"
#import "GoodsListViewController.h"

@interface HistorySearchVC ()

@end

@implementation HistorySearchVC

- (void)viewDidLoad {
    
    //告诉父类你的prestenter是什么
    self.shopHistoryP = [HistorySearchHistroyViewP new];
    //告诉只显示历史搜索界面
    self.isOnlyShowHistoryView = YES;
    // 最大搜索记录条数 15
    
    [super viewDidLoad];
    
//    [self addReSou];

    // 搜索
    [self beginSearch:^(NaviBarSearchType searchType, NBSSearchShopCategoryViewCellP *categorytagP, UILabel *historyTagLabel, LLSearchBar *searchBar) {
        // 搜索内容
        NSLog(@"%@",searchBar.text);
//        SearchResultViewController *sResaultVC = [[SearchResultViewController alloc] init];
//        sResaultVC.searchStr = searchBar.text;
//        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:sResaultVC];
//        [self presentViewController:nav animated:NO completion:nil];
        GoodsListViewController *goodsListVC = [[GoodsListViewController alloc] init];
        goodsListVC.classid = @"";
        goodsListVC.searchText = searchBar.text;
        goodsListVC.enterType = 1;
//        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:goodsListVC];
//        [self presentViewController:nav animated:NO completion:nil];
        [self.navigationController pushViewController:goodsListVC animated:YES];
    }];
    
    // 历史搜索
    [self.shopHistoryView historyTagonClick:^(UILabel *tagLabel) {
        NSLog(@"----%@",tagLabel.text);
//        SearchResultViewController *sResaultVC = [[SearchResultViewController alloc] init];
//        sResaultVC.searchStr = tagLabel.text;
//        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:sResaultVC];
//        [self presentViewController:nav animated:NO completion:nil];
        GoodsListViewController *goodsListVC = [[GoodsListViewController alloc] init];
        goodsListVC.classid = @"";
        goodsListVC.searchText = tagLabel.text;
        goodsListVC.enterType = 1;
//        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:goodsListVC];
//        [self presentViewController:nav animated:NO completion:nil];
        [self.navigationController pushViewController:goodsListVC animated:YES];
    }];
}
- (void)addReSou
{
    UILabel *label = [UILabel labelWithText:@"本地热搜榜" textColor:UIColorFromRGB(0x333333) fontSize:14];
    label.font = [UIFont boldSystemFontOfSize:14];
    [label sizeToFit];
    [self.myBGScrollView addSubview:label];
    if (self.shopHistoryView) {
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.myBGScrollView).offset(rateWidth(30));
            make.top.equalTo(self.shopHistoryView.mas_bottom).offset(rateWidth(30));
        }];
    } else {
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.myBGScrollView).offset(rateWidth(30));
            make.top.equalTo(self.myBGScrollView).offset(rateWidth(30));
        }];
    }
}

- (void)setSearchMethod
{
    //FIXME:也可以在这里实现搜索页面相关方法!!!
    @LLWeakObj(self);
    [self searchbarDidChange:^(NaviBarSearchType searchType, LLSearchBar *searchBar, NSString *searchText) {
        @LLStrongObj(self);
        //FIXME:这里是用的模拟数据!!!
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            self.resultListArray = @[@"春天", @"秋田", @"夏天-C", @"冬天"];
        });
        
    }];
}
-(void)dealloc
{
    NSLog(@"HistorySearchVC 页面销毁");
}

@end
